#!/bin/sh -e
#
# Copyright (C) 2003-2019  Dmitry V. Levin <ldv@altlinux.org>
# 
# The chrootuid@N@ helper for the hasher-priv project.
#
# SPDX-License-Identifier: GPL-2.0-or-later
#

n=
if [ -n "$1" -a -z "${1##-*}" ]; then
	n="$1"
	shift
fi

killuid()
{
	@helper@ $n killuid
}

exit_handler()
{
	local rc=$1
	killuid
	exit $rc
}

killuid

trap 'exit 143' HUP INT QUIT PIPE TERM
trap 'exit_handler $?' EXIT

@helper@ $n chrootuid@N@ "$@"
